import Vue from "vue";
import Vuex from "vuex";
import api from './api'

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
  	turnoverUserContext: {},
    timeParams: {},
    areaParams: {},
    downLink: '',
    token: '',
    sideBarWidth: false,
    selectedAge: 0,
    curAgeGroup: {},
    index: {},
    spinShow: true
  },
  getters: {
    index: state => {
      return state.index
    }
  },
  mutations: {
    SpinShow: (state, data) => {
      state.spinShow = data
    },
    SaveIndex: (state, data) => {
      state.index = data
    },
    SaveIndex: (state, data) => {
      state.index = data
    },
    SaveTimeParams: (state, data) => {
      state.timeParams = data
    },
    SaveAreaParams: (state, data) => {
      state.areaParams = data
    },
    SaveDownLink: (state, data) => {
      state.downLink = data
    },
    SaveToken: (state, data) => {
      state.token = data
      window.localStorage.setItem('token', data)
    },
    SaveSideBarWidth: (state, data) => {
      state.sideBarWidth = data
    },
    SelectAge: (state, data) => {
      state.selectedAge = data
    },
    CurAgeGroup: (state, data) => {
      state.curAgeGroup = data
    }
  },
  actions: {
    SpinShow({ commit }, params) {
      commit('SpinShow', params)
    },
    SaveToken({ commit }, params) {
      commit('SaveToken', params)
    },
    SetTimeParams({ commit }, params) {
      commit('SaveTimeParams', params)
    },
    SetAreaParams({ commit }, params) {
      commit('SaveAreaParams', params)
    },
    SetDownLink({ commit }, params) {
      commit('SaveDownLink', params)
    },
    SetSideBarWidth({ commit }, params) {
      commit('SaveSideBarWidth', params)
    },
    SelectAge ({ commit }, params) {
      commit('SelectAge', params)
    },
    CurAgeGroup ({ commit }, params) {
      commit('CurAgeGroup', params)
    },
  	// 客流数据分析
  	PassengerData ({ commit }, params) {
      return api.PassengerData(params, (res) => {
      })
    },
    // 单门店年龄性别比较
    AgeSexualStoreData ({ commit }, params) {
      return api.AgeSexualStoreData(params, (res) => {
      })
    },
    // 各分店到店性别比例
    SexualDate ({ commit }, params) {
      return api.SexualDate(params, (res) => {
      })
    },
    Index ({ commit }, params) {
      return api.Index(params, (res) => {
        commit('SaveIndex', res)
      })
    },
		// 获取中国地图
		ChinamapData ({ commit }, params) {
			return api.ChinamapData(params, (res) => {
			})
		},
		// 获取总流量周高峰时段
		RushHourData ({ commit }, params) {
			return api.RushHourData(params, (res) => {
			})
		},
    // 当天客流
    DayPeakPeriodData ({ commit }, params) {
      return api.DayPeakPeriodData(params, (res) => {
      })
    },
    // 当天客流
    provinceEntersData ({ commit }, params) {
      return api.provinceEntersData(params, (res) => {
      })
    },
    // 查询此用户下所有门店信息或品牌
    SearchAreas ({ commit }, params) {
      return api.SearchAreas(params, (res) => {
      })
    },
    // 查询此用户下所有门店信息或品牌
    Login ({ commit }, params) {
      return api.Login(params, (res) => {
      })
    },
    DayReport ({ commit }, params) {
      return api.DayReport(params, (res) => {
      })
    },
    Agegroup ({ commit }, params) {
      return api.Agegroup(params, (res) => {
      })
    },
    WeeksReport ({ commit }, params) {
      return api.WeeksReport(params, (res) => {
      })
    },
    VolumeReport ({ commit }, params) {
      return api.VolumeReport(params, (res) => {
      })
    },
    VolumeSexReport ({ commit }, params) {
      return api.VolumeSexReport(params, (res) => {
      })
    },
    VolumeAgeReport ({ commit }, params) {
      return api.VolumeAgeReport(params, (res) => {
      })
    },
    VolumeWeekReport ({ commit }, params) {
      return api.VolumeWeekReport(params, (res) => {
      })
    },
    VolumeWeekDayReport ({ commit }, params) {
      return api.VolumeWeekDayReport(params, (res) => {
      })
    },
    Logout ({ commit }, params) {
      return api.Logout(params, (res) => {
      })
    }
  }
})
